package org.example.controller;

import org.example.pojo.LoginParams;
import org.example.result.ResultData;
import org.example.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户操作控制层
 */
@RestController
@RequestMapping(value = "/user")
public class LoginController {

    @Autowired
    private ILoginService loginService;

    /**
     * 用户登录
     */
    @PostMapping(value = "/userLogin")
    public ResultData userLogin(@RequestBody LoginParams params) {
        return ResultData.success(loginService.userLogin(params));
    }

    /**
     * 退出登录
     */
    @GetMapping(value = "/exitLogin")
    public ResultData exitLogin(@RequestParam(value = "id") String id) {
        return ResultData.success(loginService.exitLogin(id));
    }
}
